package com.xiaoxiong.mami.dao.mapper;

import com.xiaoxiong.mami.dao.daomain.Cart;
import org.apache.ibatis.jdbc.SQL;

public class CartSqlProvider {

    public String insertSelective(Cart record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("cart");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("userId", "#{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsId() != null) {
            sql.VALUES("goodsId", "#{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getBatchNumber() != null) {
            sql.VALUES("batchNumber", "#{batchNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            sql.VALUES("total", "#{total,jdbcType=INTEGER}");
        }
        
        if (record.getRemark() != null) {
            sql.VALUES("remark", "#{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("createTime", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("updateTime", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=VARCHAR}");
        }
        
        if (record.getPropertyId() != null) {
            sql.VALUES("propertyId", "#{propertyId,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Cart record) {
        SQL sql = new SQL();
        sql.UPDATE("cart");
        
        if (record.getUserId() != null) {
            sql.SET("userId = #{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsId() != null) {
            sql.SET("goodsId = #{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getBatchNumber() != null) {
            sql.SET("batchNumber = #{batchNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            sql.SET("total = #{total,jdbcType=INTEGER}");
        }
        
        if (record.getRemark() != null) {
            sql.SET("remark = #{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("createTime = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("updateTime = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=VARCHAR}");
        }
        
        if (record.getPropertyId() != null) {
            sql.SET("propertyId = #{propertyId,jdbcType=INTEGER}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}